<template>
	<view>
		<view class="status_bar"></view>
		<!-- 顶部导航栏 -->
		<view class="h90 themeBac cwhite f-c-c">首页</view>

		<view class="content">
			<!-- 轮播图 -->
			<u-swiper @click="toDetail" height='300' mode='dot' :list="CarList"></u-swiper>

			<!-- 公司文化展示 -->
			<view @click="$to(`../future/future?id=${futureShow.id}`)" class="Culture">
				<image :src="baseUrl+futureShow.img" mode=""></image>
			</view>

			<!-- 推荐展示 -->
			<view class="recommend">
				<view @click="$to(`../detail/detail?id=${item.id}`)" class="recommend-item f30 cwhite"
					v-for="(item,index) in recommendList" :key="index">
					<image :src="baseUrl+item.coverimg" mode="widthFix"></image>
					<text>{{item.title}}</text>
				</view>
			</view>
		</view>
		
		<!-- <u-mask :show="show" @click="show=false">
			<view class="maskView">
				
			</view>
		</u-mask> -->
		<Tabbar></Tabbar>

		<!-- 点击底部加号展示的内容 -->
		<!--  @click="$addFlag = false" -->
		<!-- <u-mask :show="addFlag">
			<view class="btnnnn f-co-c">
				<view class="f-c-c f30 themeColor">
					<view class="btnnn f-c-c">寻找失主</view>
					<view class="btnnn f-c-c">悬赏</view>
				</view>
				<view class="close">
					<image src="../../static/index/icon_gb.png" mode="widthFix"></image>
				</view>
			</view>

		</u-mask> -->

	</view>
</template>

<script>
	import Tabbar from '../../components/Tabbar.vue'
	export default {
		components: {
			Tabbar
		},
		data() {
			return {
				baseUrl: this.$u.baseUrl,
				CarList: [],
				carLists: [],
				/* 推荐展示列表 */
				recommendList: [],
				/* 公司文化展示数据 */
				futureShow: {},
				baseUrl: this.$u.baseUrl,
				show:true
				// list: [{
				// 	pagePath: "pages/index/index",
				// 	iconPath: "static/index/icon_sy_wxz.png",
				// 	selectedIconPath: "static/index/icon_sy_xz.png",
				// 	text: "首页"
				// }, {
				// 	pagePath: "pages/square/square",
				// 	iconPath: "static/index/icon_gc_wxz.png",
				// 	selectedIconPath: "static/index/icon_gc_xz.png",
				// 	text: "广场"
				// }, {
				// 	pagePath: "pages/message/message",
				// 	iconPath: "static/index/icon_xx_wxz.png",
				// 	selectedIconPath: "static/index/icon_xx_xz.png",
				// 	text: "消息"
				// }, {
				// 	pagePath: "pages/my/my",
				// 	iconPath: "static/index/icon_wd_wxz.png",
				// 	selectedIconPath: "static/my/icon_wd_xz.png",
				// 	text: "我的"
				// }]
			}
		},
		onLoad() {
			uni.hideTabBar()
			/* 获取公司文化 */
			this.cultureinfo()
			/* 获取推荐信息 */
			this.recommendInfo()
			/* 获取轮播图信息 */
			this.rotationInfo()

		},
		 onPullDownRefresh() {
		        console.log('refresh');
		        setTimeout(function () {
		            uni.stopPullDownRefresh();
		        }, 1000);
		    },
		methods: {
			async cultureinfo() {
				const res = await this.$u.api.cultureinfo()
				this.futureShow = res.data
				console.log(this.futureShow);
			},
			async recommendInfo() {
				const res = await this.$u.api.recommendInfo()
				this.recommendList = res.data
				console.log(this.recommendList);
			},
			async rotationInfo() {
				const res = await this.$u.api.rotationInfo()
				res.data.forEach(item => {
					this.CarList.push(this.baseUrl + item.coverimg)
				})
				this.carLists = res.data
				console.log(this.carLists);
			},
			async toDetail(index) {
				console.log(this.carLists[index].id);
				const res = await this.$u.api.rotationByid({
					id: this.carLists[index].id
				})
				console.log(res);
				// item.type==='1'?$to(`../looking-for-goods/looking-for-goods?id=${res.data.goods.id}&isMe=false&status=寻找失主`):$to(`../looking-for-goods/looking-for-goods?id=${res.data.goods.id}&isMe=false&status=赏金`)
				
				res.success ? res.data.type==='1'?this.$to(`../looking-for-goods/looking-for-goods?id=${res.data.goods.id}&isMe=false&status=寻找失主`):this.$to(`../looking-for-goods/looking-for-goods?id=${res.data.goods.id}&isMe=false&status=赏金`) : this.$u.toast(res.msg)
			}
		}
	}
</script>

<style>
	/* .close image {
		width: 70rpx;
		margin-top: 50rpx;
	}

	.btnnnn {
		position: fixed;
		z-index: 999;
		bottom: 150rpx;
		left: 50%;
		margin-left: -270rpx;
		/* background-color: #007AFF; 
	} */
	
	/* .maskView{
		width: 300rpx;
		height: 300rpx;
		background-color: #FFFFFF;
	} */

	.btnnn {
		border: 1rpx solid #373737;
		width: 250rpx;
		height: 60rpx;
		margin: 0 10rpx;
		border-radius: 10rpx;
		background-color: #FFFFFF;
	}

	.content {
		padding: 10rpx 30rpx;
	}

	.Culture {
		height: 180rpx;
		width: 100%;
	}

	.Culture image {
		width: 100%;
		height: 100%;
		margin: 20rpx 0;
	}

	.recommend {
		display: flex;
		flex-wrap: wrap;
		margin: 40rpx 0;
		justify-content: space-between;
	}

	.recommend-item {
		width: 331rpx;
		background-color: #707070;
		border-radius: 15rpx;
		margin-bottom: 20rpx;
	}

	.recommend-item text {
		padding: 5rpx;
	}

	.recommend-item image {
		width: 100%;
		height: 288rpx !important;
		border-radius: 15rpx;
	}
</style>
